home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK2.toast / Development Kits (Disc 2) / Word Services SDK 1.0.8 / Writeswell Jr 1.2.3 Sources ƒ / Library Source / FindBrowser.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-18  |  1.7 KB  |  79 lines  |  [TEXT/CWIE]

  1. /* FindBrowser.c
  2.  * Look for and launch a Web browser that supports the GetURL event
  3.  * Copyright ©1996 Michael D. Crawford.  All Rights Reserved.
  4.  * You may use this code on the condition that you read the following web page:
  5.  * http://www.webcom.com/wordserv/
  6.  *  1 Jul 96 Mike Crawford crawford@scruznet.com
  7.  */
  8.  
  9. #include "FindBrowser.h"
  10. #include "FindProcess.h"
  11. #include "SearchForApp.h"
  12.  
  13. OSErr LookForProcess( OSType creator, Boolean *gotItPtr );
  14.  
  15. OSErr FindBrowser( OSType *creatorPtr )
  16. {
  17.     OSType    **creators;
  18.     OSErr    err;
  19.     short    i;
  20.     short    numCreators;
  21.     Boolean    gotIt;
  22.     ProcessSerialNumber psn;
  23.     ProcessInfoRec pInfo;
  24.     FSSpec fSpec;
  25.     Str255    procName;
  26.     VolumeParam    vPB;
  27.     
  28.     *creatorPtr = 'null';
  29.     
  30.     creators = (OSType**)GetResource( 'Cr8r', 128 );
  31.     if ( !creators )
  32.         return resNotFound;
  33.     
  34.     numCreators = GetHandleSize( (Handle)creators ) / sizeof( OSType );
  35.     
  36.     // Search the running processes for one we know about
  37.     
  38.     for ( i = 0; i < numCreators; i++ ){
  39.         gotIt = FindAProcess( (*creators)[ i ],
  40.                                 &psn,
  41.                                 &pInfo,
  42.                                 &fSpec,
  43.                                 procName );
  44.         if ( gotIt ){
  45.             *creatorPtr = (*creators)[ i ];
  46.             return noErr;
  47.         }
  48.     }
  49.     
  50.     vPB.ioCompletion = (IOCompletionUPP)NULL;
  51.     vPB.ioVolIndex = 1;
  52.     vPB.ioNamePtr = (StringPtr)NULL;
  53.     
  54.     do {
  55.         err = PBGetVInfoSync( (ParamBlockRec*)&vPB );
  56.         if ( err == nsvErr )
  57.             return noErr;            // Out of volumes to search, haven't found any browsers
  58.         if ( err )
  59.             return err;
  60.         
  61.         err = SearchVolForBrowser( vPB.ioVRefNum,
  62.                                     &gotIt,
  63.                                     creators, 
  64.                                     numCreators, 
  65.                                     &fSpec, 
  66.                                     creatorPtr );
  67.         if ( gotIt ){
  68.             err = LaunchTheApp( &fSpec );
  69.             return err;
  70.                 
  71.         }
  72.         
  73.         vPB.ioVolIndex++;
  74.     }while( !err && !gotIt );
  75.         
  76.     return noErr;
  77. }
  78.  
  79.